Selectively Including files in C#.net web application [migrated]
Posted
by
segnosaur
on Programmers
See other posts from Programmers
or by segnosaur
Published on 2014-05-27T20:41:01Z
Indexed on
2014/05/28
4:00 UTC
Read the original article
Hit count: 158
I am attempting to modify an application with the following characteristics:
- Written in C#.net
- Using Visual Studio 2010
- The application uses a Master sheet to maintain commonality
The Master sheet has the following:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="mysheet.master.cs" Inherits="master_mysheet" %>
Now, currently, the master sheet has an include file that brings in a common footer:
#include file="inc/my-footer.inc"
Here's what I want to do: I would like to modify the master sheet to be able to read in a footer based on the value contained in a session variable... i.e. (not real code, but just something to give an idea of what I want) if session("x") = "a" then #include file="inc/my-footer1.inc" else #include file="inc/my-footer2.inc"
My first instinct was to go with some vbscript:
<script type="text/vbscript" language="vbscript">
document.write("vbscript example.")
</script>
However, it doesn't run the vbscript code automatically on page load.
Does anyone know: - The syntax I need to actually get this to work? i.e. to get the vbscript to run automatically on page load, AND to do the page include? - Or, is there a better way to go about this? (perhaps by doing some coding in C#)
Note: I am experienced in C#; however, I haven't done any vbscript since the days of ASP classic, so my knowledge there is out of date.
© Programmers or respective owner